//
//  UIBarButtonItem+Extension.swift
//  传智新浪微博
//
//  Created by app on 17/6/2.
//  Copyright © 2017年 app. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    /// 创建 UIBarbuttonItem
    convenience init(title: String, fontSize: CGFloat = 16, targrt: AnyObject, action: Selector, isBack: Bool = false) {
        
        let btn = UIButton.lwh_textButton(title: title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        btn.addTarget(targrt, action: action, for: .touchUpInside)
        
        if isBack {
            let imageName = "navigationBar_back"
            btn.setImage(UIImage(named: imageName), for: UIControlState(rawValue: 0))
            btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
            
            btn.sizeToFit()
        }
        
        // self.init 实例化 UIBarButtonItem
        self.init(customView: btn)
    }
}
